<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>档案管理</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
  <script src="libs/layer/layer.js"></script>
  <link href="libs/Font-Awesome/css/font-awesome.min.css" rel="stylesheet">
  <script src="libs/handlebars.min.js"></script>
  <script src="libs/d3.v3.min.js" charset="utf-8"></script>
  <link href="libs/nv.d3.min.css" rel="stylesheet">
  <script src="libs/nv.d3.min.js"></script>
  <script src="libs/js.cookie-2.1.0.min.js"></script>
</head>
<body>
  <div class="container">
    <div class="row">
      <div class="page-header">
        <h2>档案管理</h2>
      </div>
    </div>
    <div class="row">
      <div class="col-md-8">
        <ul class="nav nav-pills">
          <li role="presentation" class="active"><a href="index.html">首页</a></li>
          <li role="presentation"><a href="archive-append.html">添加档案</a></li>
          <li role="presentation"><a href="search.html">检索档案</a></li>
          <li role="presentation"><a href="stats.html">统计</a></li>
        </ul>
      </div>
      <div class="col-md-4" id="search-box-archive"></div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <hr/>
      </div>
    </div>
  </div>

  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <div class="panel panel-primary">
          <div class="panel-heading">最近浏览（当前用户）</div>
          <div class="panel-body" id="list_view"></div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <div class="panel panel-success">
          <div class="panel-heading">最新添加（当前用户）</div>
          <div class="panel-body" id="list_append"></div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <div class="panel panel-warning">
          <div class="panel-heading">最近修改</div>
          <div class="panel-body" id="list_update"></div>
        </div>
      </div>
    </div>
  </div>

  <div class="container">
    <div class="row">
      <div class="col-md-12" id="chart">
        <p class="text-center">
          <br/>
          <hr/>
          <strong>使用统计</strong>
          <svg style="height:480px;width:100%"></svg>
          <br/>
        </p>
      </div>
    </div>
  </div>

  <div class="container" id="page-footer"></div>

  <script src="libs/react/15.1.0/react.min.js"></script>
  <script src="libs/react/15.1.0/react-dom.min.js"></script>
  <script src="libs/babel-core/5.8.34/browser.min.js"></script>
  <script type="text/babel" src="javascript/search-box.js"></script>
  <script type="text/babel" src="javascript/page-footer.js"></script>
  <script id="template" type="text/x-handlebars-template">
    {{#each item}}
    <div class="panel panel-default col-md-3">
      <div class="panel-body">
        <dl>
          <dt>档案号</dt>
          <dd>{{danganhao}}</dd>
          <dt>姓名</dt>
          <dd>{{xingming}}</dd>
          <dt>身份证</dt>
          <dd>{{shenfenzheng}}</dd>
          <dt>时间</dt>
          <dd>{{riqi}} {{shijian}}</dd>
        </dl>
        <a href="archive-info.html?archiveId={{id}}" class="btn btn-default btn-block">查看</a>
      </div>
    </div>
    {{/each}}
  </script>
  <script type="text/javascript">
    if (!Cookies.get("user")) {
      window.location.href = 'login.html';
    }
  </script>
  <script type="text/javascript">
  $(function () {
    $.getJSON('stats/user/view/4.action', function (res) {
      var data = {'item': res};
      var t = Handlebars.compile($('#template').html());
      $('#list_view').html(t(data));
    });
    $.getJSON('stats/user/append/4.action', function (res) {
      var data = {'item': res};
      var t = Handlebars.compile($('#template').html());
      $('#list_append').html(t(data));
    });
    $.getJSON('stats/all/update/4.action', function (res) {
      var data = {'item': res};
      var t = Handlebars.compile($('#template').html());
      $('#list_update').html(t(data));
    });
    $.getJSON('stats/currentUser.action', function (res) {
      nv.addGraph(function() {
        var chart = nv.models.pieChart()
          .x(function(d) {
            return d.caozuo
          }).y(function(d) {
            return d.counter
          }).showLabels(true)
          .labelType('percent');
        d3.select("#chart svg")
          .datum(res)
          .transition().duration(350)
          .call(chart);
        return chart;
      });
    })
  })
  </script>
</body>
</html>
